package com.beyond.trace.controller;

import com.beyond.trace.service.ITraceProductService;
import com.beyond.trace.service.TraceScanStatisticsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @BelongsProject: trace
 * @BelongsPackage: com.beyond.trace.controller
 * @Author: zhangq
 * @CreateTime: 2023-01-06  11:37
 * @Description: 扫码统计对象功能接口
 */
@Api(tags = "扫码统计对象功能接口")
@RestController
@RequestMapping("/trace/scanStatistics")
public class TraceScanStatisticsController extends BaseController {

    @Autowired
    private TraceScanStatisticsService scanStatisticsService;
    @Autowired
    private ITraceProductService traceProductService;

    @ApiOperation("统计扫码情况")
    @GetMapping("/scanStatistics")
    public AjaxResult scanStatistics() {
        return AjaxResult.success(scanStatisticsService.homeShow());
    }

    @GetMapping("/group/product")
    @ApiOperation("实时查询")
    public AjaxResult groupProduct(){
        return AjaxResult.success(this.scanStatisticsService.groupProduct());
    }

    @GetMapping("/product/scan")
    @ApiOperation("大屏产品类型和扫码次数统计")
    public AjaxResult scanProduct(){
        Map<String,Integer> result = new HashMap<>(2);
        result.put("productNum",traceProductService.count());
        result.put("scanCodeNum",scanStatisticsService.count());
        return AjaxResult.success(result);
    }
}
